package com.bw.module_communication

import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ToastUtils
import com.bw.lib_base.path.RouterPath
import com.bw.lib_common.view.BaseMvvmActivity
import com.bw.module_communication.databinding.ActivityCommunicationBinding
import com.hyphenate.EMCallBack
import com.hyphenate.chat.EMClient
import com.hyphenate.easeui.widget.EaseTitleBar
import dagger.hilt.android.AndroidEntryPoint

/**
 * 工单-智慧园区-即时通讯
 */

@Route(path = RouterPath.PATH_COMMUNICATION_ACTIVITY)
class CommunicationActivity : BaseMvvmActivity<ActivityCommunicationBinding>() {
    override fun observeDataChange() {
        findViewById<EaseTitleBar>(R.id.title_bar).setLeftLayoutClickListener {
            finish()
        }

        supportFragmentManager.beginTransaction()
            .replace(R.id.container, CommunicationFragment())
            .commit()
    }

    override fun initView() {
        EMClient.getInstance().login("17382856680", "123", object : EMCallBack {
            // 登录成功回调
            override fun onSuccess() {
                ToastUtils.showLong("登录成功")
            }

            // 登录失败回调，包含错误信息
            override fun onError(code: Int, error: String) {

            }

            override fun onProgress(progress: Int, status: String?) {

            }
        })
    }

    override fun getLayoutId(): Int = R.layout.activity_communication


}